<template>
	<el-dialog title="" width="1000px" visible :show-close="false" :append-to-body="true" class="wrap">
		<i class="el-icon-close close" @click="cancel" style="color: white;z-index: 99;"></i>
		<div class="bt">课表调整</div>
		<div style="text-align: left;">
			<el-button type="danger" @click="cancel">退出</el-button>
		</div>
		<!--<ul style="margin-left: 25px;text-align: left;" v-if="this.ctlist1.length>0">
			<li style=" color: red;">本节课与以下老师有冲突</li>
			<li style="margin-left: 25px; font-size: 22px;height: 50px;line-height: 50px;" v-for="i in this.ctlist1">{{i.bjmc}}&nbsp;&nbsp;{{i.jsmc}}&nbsp;&nbsp;{{i.zwm}}&nbsp;&nbsp;{{i.sj}}&nbsp;&nbsp;{{i.sjd}}</li>
		</ul>-->
		<ul style="margin-left: 10px;" v-if="this.ctlist2.length>0">
			<li style=" color: red;margin-left: 10px;">冲突列表</li>
			<li style="margin-left: 10px; font-size: 15px;height: 50px;line-height: 50px;" v-for="i in this.ctlist2">{{i.bjmc}}&nbsp;&nbsp;{{i.jsmc}}&nbsp;&nbsp;{{i.zwm}}&nbsp;&nbsp;{{i.sj}}&nbsp;&nbsp;{{i.sjd}}</li>
		</ul>
		<div style="overflow: hidden;">
			<el-form label-width="100px" class="form1">
				<h2>基本信息</h2>
				<el-form-item style="margin-top: 10px; height: 20px;" label="班级名称：">
					{{pkxxlist.mc}}
				</el-form-item>
				<el-form-item style="height: 20px;" label="老师名称：">
					{{pkxxlist.lsmc}}
				</el-form-item>
				<el-form-item style="height: 20px;" label="教室名称：">
					{{pkxxlist.jsmc}}
				</el-form-item>
				<el-form-item style="height: 20px;" label="上课时间：">
					{{pkxxlist.sj}}
				</el-form-item>
				<el-form-item style="height: 20px;" label="是否考勤：">
					{{pkxxlist.isskmc}}
				</el-form-item>
				<el-form-item style="height: 20px;" label="Day：">
					{{pkxxlist.day}}
				</el-form-item>
			</el-form>
			<el-tabs v-model="activeName">
				<el-tab-pane label="调整上课老师" name="first">
					<el-form label-width="100px" class="form">
						<div style="width: 100px; font-size: 20px; text-align: right;">&nbsp;&nbsp;&nbsp;</div>
						<el-form-item label="老师调整">
							<el-select v-model="lsid" placeholder="请选择代课老师">
								<el-option :label="v.zwm" :value="v.id+''" v-for="v in lsboxlist"></el-option>
							</el-select>
							<el-button size="small" type="primary" @click="editdk">修改</el-button>
						</el-form-item>
					</el-form>
				</el-tab-pane>
				<el-tab-pane label="调整上课时间" name="second">
					<el-form label-width="100px" class="form">
						<div style="width: 100px; font-size: 20px; text-align: right;">&nbsp;&nbsp;&nbsp;</div>
						<el-form-item label="上课日期">
							<el-date-picker v-model="vrq" size="mini" type="date" placeholder="请选择时间" class="inp"> </el-date-picker>
						</el-form-item>
						<el-form-item label="教室调整">
							<el-select v-model="jsid" placeholder="请选择教室" style="width: 100px;">
								<el-option :label="v.jsmc" :value="v.id" v-for="v in jsboxlist"></el-option>
							</el-select>
							<el-select v-model="sjd1" style="width: 80px;">
								<el-option v-for=" v in hourlist " :label="v" :value="v"></el-option>
							</el-select>
							<el-select v-model="sjd2" style="width: 80px;">
								<el-option v-for=" v in minslist " :label="v" :value="v"></el-option>
							</el-select>
							<span class="a" style=""> &nbsp;&nbsp;--&nbsp;&nbsp; </span>
							<el-select v-model="sjd3" style="width: 80px;">
								<el-option v-for=" v in hourlist " :label="v" :value="v"></el-option>
							</el-select>
							<el-select v-model="sjd4" style="width: 80px;">
								<el-option v-for=" v in minslist " :label="v" :value="v"></el-option>
							</el-select>
							<el-button size="small" type="primary" @click="editsjd">修改</el-button>
						</el-form-item>
					</el-form>
				</el-tab-pane>
				<el-tab-pane label="本班课表调整(*)" name="third">
					<div style="width: 100px; font-size: 20px; text-align: right;">&nbsp;&nbsp;&nbsp;</div>
					<div style="width: 40%; text-align: center; ">
						<el-button size="small" type="primary" @click="up('1')">提早一周</el-button>
						<el-button size="small" type="primary" @click="up('2')">延迟一周</el-button>
					</div>
				</el-tab-pane>
				<el-tab-pane label="停课调整(*)" name="fourth">
					<div style="width: 100px; font-size: 20px; text-align: right;">&nbsp;&nbsp;&nbsp;</div>
					<div style="width: 65%; text-align: center; ">
                        <p style="width: 100%;">
						<el-button size="small" type="primary" @click="xhtz()">停课向后调整</el-button>
						</p>
						<span style="color: red;">注：停课向后调整就是将课表向后调一节课</span>
						
					</div>
				</el-tab-pane>
			</el-tabs>
		</div>

	</el-dialog>
</template>
<script type="text/javascript">
	import qs from 'qs'
	export default {
		props: ['params'],
		data() {
			return {
				pkxxlist: '',
				activeName: 'first',
				ctlist1: [],
				ctlist2: [],
				vrq: '',
				lsid: '',
				jsid: '',
				ms: '',
				lsboxlist: [],
				jsboxlist: [],
				sjd1: '',
				sjd2: '',
				sjd3: '',
				sjd4: '',
				hourlist: ['', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22'],
				minslist: ['', '00', '05', '10', '15', '20', '25', '30', '35', '40', '45', '50', '55'],
				// 			

			}
		},
		created() {
			//		 this.form.id = this.params.row.id;
			//        this.loadinfo();
			console.log(this.params, 6565)
			this.id = this.params.id
			if(this.params.jsid) {
				this.vbjmc = this.params.bjmc
				this.jsid = this.params.jsid + ''
				this.sjd1 = this.params.sjd.substring(0, 2)
				this.sjd2 = this.params.sjd.substring(3, 5)
				this.sjd3 = this.params.sjd.substring(7, 9)
				this.sjd4 = this.params.sjd.substring(10, 12)
				if(this.params.dklsid != 0) {
					this.lsid = this.params.dklsid
				}
				//			this.sj = this.params.sj
				this.vrq = this.params.sj
			}
//			this.ls();
			this.js();
			this.getbkct()
			this.getpkxx()
		},
		methods: {
			getpkxx() {
				var logininfo = JSON.parse(localStorage.logininfo);
				var params2 = qs.stringify({
					yhid: logininfo.id,
					xxid: logininfo.xxid,
					id: this.id,
				})
				//执行
				this.axios.post(this.$store.state.api + 'pk/info', params2)
					.then(res => {
						console.log(res, 898981111111)
						if(res.data.code == 1) {
							this.pkxxlist = res.data.data;
							this.pkids = res.data.data.id;
//				alert(this.pkids)
				            this.ls();
							
						}
					}).catch(res => {
						console.log(res)
					})
			},
			getbkct() {
				var logininfo = JSON.parse(localStorage.logininfo);
				var params2 = qs.stringify({
					yhid: logininfo.id,
					xxid: logininfo.xxid,
					pkid: this.id,
					isys: 11,
				})
				//执行
				this.axios.post(this.$store.state.api + 'pk/pkcf', params2)
					.then(res => {
						//						console.log(res,89898)
						if(res.data.code == 1) {
							//							this.getCourseList()
							this.ctlist1 = res.data.data.ls
							this.ctlist2 = res.data.data.lst1
						}
					}).catch(res => {
						console.log(res)
					})
			},
			up(lx) {
				var logininfo = JSON.parse(localStorage.logininfo);
				var params2 = qs.stringify({
					lx: lx,
					yhid: logininfo.id,
					xxid: logininfo.xxid,
					pkid: this.id,
				})
				//执行
				this.axios.post(this.$store.state.api + 'pk/qykb', params2)
					.then(res => {
						console.log(res)
						if(res.data.code == 1) {
							//							this.getCourseList()
							this.$emit('close', {
									type: 'edit',
									cancel: false
								});
							this.$message.warning(res.data.msg)
						}
					}).catch(res => {
						console.log(res)
					})
			},
			xhtz() {
				var logininfo = JSON.parse(localStorage.logininfo);
				var params2 = qs.stringify({
					yhid: logininfo.id,
					xxid: logininfo.xxid,
					pkid: this.id,
				})
				//执行
				this.axios.post(this.$store.state.api + 'pk/tktjkb', params2)
					.then(res => {
						console.log(res)
						if(res.data.code == 1) {
							this.$emit('close', {
									type: 'edit',
									cancel: false
								});
							this.$message.success(res.data.msg)
						}else{
							this.$message.warning(res.data.msg)
						}
					}).catch(res => {
						console.log(res)
					})
			},
			//			down() {
			//				var params2 = qs.stringify({
			//					id: this.id,
			//				})
			//				//执行
			//				this.axios.post(this.$store.state.api + 'pk/down', params2)
			//					.then(res => {
			//						//						console.log(res)
			//						if(res.data.code == 1) {
			//							this.getCourseList()
			//						}
			//					}).catch(res => {
			//						console.log(res)
			//					})
			//
			//			},
			//			supplyCourse(jsmc, jsid) {
			//
			//				this.dialogVisible = true;
			//				this.form.classroomName = jsmc;
			//				this.form.classroomID = jsid
			//				this.ls();
			//			},
			editdk() {
				this.$confirm('是否确定修改代课老师', '提示', {
					type: 'warning'
				}).then(() => {
					this.dialogVisible = false;
					var params2 = qs.stringify({
						id: this.id,
						dkls: this.lsid,
					})
					//执行
					this.axios.post(this.$store.state.api + 'pk/update', params2)
						.then(res => {
							if(res.data.code == 1) {
								this.$emit('close', {
									type: 'edit',
									cancel: false
								});
								this.$message.success(res.data.msg);
								this.$store.state.loading = false;
							} else {
								this.$message.warning(res.data.msg);
								this.$store.state.loading = false;
							}
							// this.dialogVisible = false;
						}).catch(res => {
							this.$message.danger("服务器异常!")
							this.$store.state.loading = false;
						})
				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消保存'
					});

				})
			},
			editsjd() {
				this.$confirm('是否进行课程调整?', '提示', {
					type: 'warning'
				}).then(() => {
					var time1 = ''
					var sjd = ''
					if(this.sjd1) {
						sjd = this.sjd1 + ":" + this.sjd2 + "--" + this.sjd3 + ":" + this.sjd4;
					} else {
						sjd = this.sjd
					}
					time1 = this.$.getLocalTimeNo0(Date.parse(this.vrq));
					this.dialogVisible = false;
					var params2 = qs.stringify({
						sj: time1,
						id: this.id,
						jsid: this.jsid,
						sjdid: sjd
					})
					//执行
					this.axios.post(this.$store.state.api + 'pk/updatekb', params2)
						.then(res => {
							// this.dialogVisible = false;
							//							console.log(res)
							this.$emit('close', {
									type: 'edit',
									cancel: false
								});
						}).catch(res => {
							console.log(res)
						})
				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消保存'
					});

				})
			},
			ls() {
//				alert(this.pkids)
				var logininfo = JSON.parse(localStorage.logininfo);
				var params2 = qs.stringify({
					pkid:this.pkids,
					yhid:logininfo.id,
					xxid: logininfo.xxid
				})
				//执行
				this.axios.post(this.$store.state.api + 'ls/getdkls', params2)
					.then(res => {
//						console.log(res,'ffff')
						let data = res.data.data.list;
						this.lsboxlist = data;
					}).catch(res => {})

			},
			js() {
				var logininfo = JSON.parse(localStorage.logininfo);
				var params2 = qs.stringify({
					yhid: logininfo.id,
					xxid: logininfo.xxid
				})
				//执行
				this.axios.post(this.$store.state.api + 'xxjs/getjsxlk', params2)
					.then(res => {
						//						console.log(res, 1111)
						let data = res.data.data.list;
						this.jsboxlist = data;
					}).catch(res => {})

			},
			cancel() {
				this.$emit('close', {
					type: 'edit',
					cancel: true
				})
			},
		},
		computed: {
			jg() {
				let number = this.form.jcjg * this.form.ks;
				if(number <= 0) {
					return 0.00
				}
				return number;
			},
		}
	}
</script>
<style lang="less" scoped>
	.wrap {
		text-align: center;
	}
	
	.bt {
		position: absolute;
		width: 100%;
		height: 50px;
		margin: 0 auto;
		top: 0;
		left: 0;
		background: #50BFFF;
		margin-bottom: 20px;
		color: white;
		text-align: left;
		line-height: 50px;
		font-size: 17px;
		padding-left: 15px;
	}
	
	.form1 {
		width: 250px;
		text-align: left;
		float: left;
		padding-right: 20px;
		margin-top: 10px;
	}
	
	.form {
		text-align: left;
	}
	
	.input {
		width: 300px;
		display: inline-block;
	}
	
	.select-block {
		display: block;
	}
	
	.submit {
		width: 120px;
	}
</style>